Skip to main content

Using Nature2D Plugins

So what are these "Plugins" all about? Don't get confused, these plugins are not Roblox Studio plugins. These plugins are essentially utility modules that many people may find useful! I decided to create some of them for practices which are prominent, like creating custom RigidBody structures and being able to drag and move RigidBodies here and there using the mouse button.

There are 3 Plugins available as of now

  • Quad - To create a 4 sided custom RigidBody structure given 4 points.
  • Triangle - To create a triangular custom RigidBody structure given 3 points.
  • MouseConstraint - A tool for dragging and moving RigidBodies using the mouse cursor.

In order to use plugins, you may require them in your script like this:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Plugins = require(ReplicatedStorage.Nature2D.Plugins)

Example of the Triangle Plugin:

--  Plugins.Triangle(a: Vector2, b: Vector2, c: Vector2)s

local TriangleBody = Engine:Create("RigidBody", {
Mass = 5,
Structure = Plugins.Triangle(Vector2.new(10, 10), Vector2.new(10, 20), Vector2.new(0, 20)),
Collidable = true,
Anchored = false
})

Example of the Quad Plugin:

-- Plugins.Quad(a: Vector2, b: Vector2, c: Vector2, d: Vector2)

local QuadBody = Engine:Create("RigidBody", {
Mass = 5,
Structure = Plugins.Quad(Vector2.new(0, 0), Vector2.new(20, 20), Vector2.new(0, 20), Vector2.new(20, 0)),
Collidable = true,
Anchored = false
})

Example of MouseConstraint:

-- Plugins.MouseConstraint(engine: Engine, range: number)

-- RigidBodies that are closest to the mouse
-- and under a radius of 10 pixels can be dragged around by holding and moving the mouse.
local DestroyMouseConstraint = Plugins.MouseConstraint(Engine, 10)
task.wait(5)
DestroyMouseConstraint() -- Makes the mouse constraint unusable after 5 seconds. Can be used again by calling Plugins.MouseConstraint()

If you wish to see more plugins be added, do share some feedback with me. If you wish to have your plugins be added to Nature2D, open a pull request at the Github Repository!